﻿using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using Csla;

namespace RMSM
{
    [Serializable()]
    public class KBHTHHReduceBOCollection : Csla.BusinessListBase<KBHTHHReduceBOCollection, KBHTHHReduceBO>
    {
        #region BindingList Overrides
        protected override object AddNewCore()
        {
            KBHTHHReduceBO _KBHTHHReduceBO = KBHTHHReduceBO.NewChildKBHTHHReduceBO();
            OnAddingNew(new System.ComponentModel.AddingNewEventArgs(_KBHTHHReduceBO));
            Add(_KBHTHHReduceBO);
            return _KBHTHHReduceBO;
        }
        #endregion BindingList Overrides
        //==========================================================================

        #region Factory Methods
        private KBHTHHReduceBOCollection()
        {
        }

        public static KBHTHHReduceBOCollection NewKBHTHHReduceBOCollection()
        {
            return new KBHTHHReduceBOCollection();
        }

        public static KBHTHHReduceBO NewKBHTHHReduceBO()
        {
            return KBHTHHReduceBO.NewChildKBHTHHReduceBO();
        }

        public static KBHTHHReduceBOCollection GetKBHTHHReduceBOCollection()
        {
            SPParam spParam = new SPParam("KBHTHHID", "ASC", "WHERE Deleted=0");
            return DataPortal.Fetch<KBHTHHReduceBOCollection>(spParam);
        }

        public static KBHTHHReduceBOCollection GetKBHTHHReduceBOCollection(string where)
        {
            SPParam spParam = new SPParam("KBHTHHID", "ASC", "WHERE Deleted=0" + (where != "" ? " AND " : "") + where);
            return DataPortal.Fetch<KBHTHHReduceBOCollection>(spParam);
        }

        public static KBHTHHReduceBOCollection GetKBHTHHReduceBOCollection(string where, string orderByColumn)
        {
            SPParam spParam = new SPParam((orderByColumn == "" ? "KBHTHHID" : orderByColumn), "ASC", "WHERE Deleted=0" + (where != "" ? " AND " : "") + where);
            return DataPortal.Fetch<KBHTHHReduceBOCollection>(spParam);
        }

        public static KBHTHHReduceBOCollection GetKBHTHHReduceBOCollection(string where, string orderByColumn, string orderByExpression)
        {
            SPParam spParam = new SPParam((orderByColumn == "" ? "KBHTHHID" : orderByColumn), (orderByExpression == "" ? "ASC" : orderByExpression), "WHERE Deleted=0" + (where != "" ? " AND " : "") + where);
            return DataPortal.Fetch<KBHTHHReduceBOCollection>(spParam);
        }
        #endregion Factory Methods
        //==========================================================================

        #region Criteria
        [Serializable()]
        private class Criteria
        {
            public Criteria()
            {
            }
        }

        [Serializable()]
        public class FilterCriteria
        {
            public FilterCriteria()
            {
            }
        }
        #endregion Criteria
        //==========================================================================

        #region Fetch
        [Transactional(TransactionalTypes.TransactionScope)]
        private void DataPortal_Fetch(SPParam spParam)
        {
        }
        #endregion Fetch
        //==========================================================================

        #region Update
        [Transactional(TransactionalTypes.TransactionScope)]
        protected override void DataPortal_Update()
        {
            Update();
        }

        internal void Update()
        {
        }
        #endregion Update
        //==========================================================================

        #region Business Method
        public KBHTHHReduceBO GetKBHTHHReduceBO(int _KBHTHHID)
        {
            KBHTHHReduceBO returnObject = null;
            foreach (KBHTHHReduceBO _KBHTHHReduceBO in this)
            {
                if (_KBHTHHReduceBO.KBHTHHID == _KBHTHHID)
                {
                    returnObject = _KBHTHHReduceBO;
                    break;
                }
            }
            return returnObject;
        }

        public int GetIndex(int _KBHTHHID)
        {
            if (_KBHTHHID == null)
                return -1;

            int length = this.Count;
            for (int i = 0; i < length; i++)
                if (this[i].KBHTHHID == _KBHTHHID)
                    return i;

            return -1;
        }

        public void Remove(int KBHTHHID)
        {
            foreach (KBHTHHReduceBO _KBHTHHReduceBO in this)
            {
                if (_KBHTHHReduceBO.KBHTHHID == KBHTHHID)
                {
                    try
                    {
                        this.Remove(_KBHTHHReduceBO);
                    }
                    catch { }
                    break;
                }
            }
        }
        #endregion Business Method
        //==========================================================================
    }
}
